<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 
 * @property int $uid 
 * @property int $main_uid 
 * @property int $scheme_id 方案ID
 * @property string $name 方案名称
 * @property string $content 操作内容
 * @property int $type 类型
 * @property string $created_at 操作时间
 * @property-read null|\Hyperf\Database\Model\Collection|ChRobot[] $robots 
 */
class ChOperationLog extends MineModel
{
    public bool $timestamps = false;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_operation_log';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'uid', 'main_uid', 'scheme_id', 'name', 'content', 'type', 'created_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'uid' => 'integer', 'main_uid' => 'integer', 'scheme_id' => 'integer', 'type' => 'integer'];


    public function robots(): \Hyperf\Database\Model\Relations\BelongsToMany
    {
        return $this->belongsToMany(ChRobot::class, 'ch_operation_log_robot', 'log_id', 'robot_id');
    }

    public function user(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChUser::class, 'id', 'uid');
    }
}
